Skip to content

feat(node)!: Make channel-based instrumentation the default#22501

Draft
andreiborza wants to merge 32 commits into
developfrom
ab/channel-based-default
Draft

feat(node)!: Make channel-based instrumentation the default#22501
andreiborza wants to merge 32 commits into
developfrom
ab/channel-based-default

Conversation

@andreiborza

@andreiborza andreiborza commented Jul 22, 2026

Copy link
Copy Markdown
Member

What

Make orchestrion diagnostics-channel instrumentation the default in @sentry/node and remove the experimentalUseDiagnosticsChannelInjection() opt-in.

Why

The channel-based instrumentations shipped opt-in in v10. Making them the default in v11 unlocks instrumentation at run and build time.

Removal of the vendored OTel/IITM code is intentionally out of scope; it is tracked separately as follow-up.

Closes: #22345

Comment thread packages/aws-serverless/src/init.ts
Comment thread packages/node/src/sdk/index.ts
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.79 kB - -
@sentry/browser - with treeshaking flags 26.23 kB - -
@sentry/browser (incl. Tracing) 46.31 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.08 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.12 kB - -
@sentry/browser (incl. Tracing, Replay) 85.59 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.23 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.29 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 102.97 kB - -
@sentry/browser (incl. Feedback) 44.96 kB - -
@sentry/browser (incl. sendFeedback) 32.59 kB - -
@sentry/browser (incl. FeedbackAsync) 37.64 kB - -
@sentry/browser (incl. Metrics) 28.88 kB - -
@sentry/browser (incl. Logs) 29.11 kB - -
@sentry/browser (incl. Metrics & Logs) 29.8 kB - -
@sentry/react 29.59 kB - -
@sentry/react (incl. Tracing) 48.6 kB - -
@sentry/vue 33.22 kB - -
@sentry/vue (incl. Tracing) 48.28 kB - -
@sentry/svelte 27.81 kB - -
CDN Bundle 30.11 kB - -
CDN Bundle (incl. Tracing) 48.16 kB - -
CDN Bundle (incl. Logs, Metrics) 31.69 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.48 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.95 kB - -
CDN Bundle (incl. Tracing, Replay) 85.73 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.02 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.5 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.79 kB - -
CDN Bundle - uncompressed 89.77 kB - -
CDN Bundle (incl. Tracing) - uncompressed 144.87 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.48 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 148.85 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.24 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.11 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.07 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 277.81 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 281.76 kB - -
@sentry/nextjs (client) 51.13 kB - -
@sentry/sveltekit (client) 46.75 kB - -
@sentry/core/server 80.18 kB - -
@sentry/core/browser 51.99 kB - -
@sentry/node 140.85 kB +13.01% +16.21 kB 🔺
⛔️ @sentry/node (incl. diagnostics channel injection) (max: null) 0 B removed removed
@sentry/node/import (ESM hook with diagnostics-channel injection) 70.03 kB +0.01% +2 B 🔺
@sentry/node - without tracing 80.18 kB +7.25% +5.42 kB 🔺
@sentry/aws-serverless 88.17 kB +4.65% +3.92 kB 🔺
@sentry/cloudflare (withSentry) - minified 196.64 kB - -
@sentry/cloudflare (withSentry) 483.88 kB - -

View base workflow run

Comment thread packages/nextjs/src/server/index.ts
Comment thread packages/node/src/integrations/tracing/mysql/index.ts
Comment thread packages/node/src/integrations/tracing/express.ts
Comment thread packages/node/src/integrations/tracing/index.ts
Comment thread dev-packages/e2e-tests/test-applications/node-express/tests/trpc.test.ts Outdated
Comment thread packages/nextjs/src/server/index.ts
andreiborza and others added 23 commits July 23, 2026 13:53
Make orchestrion diagnostics-channel injection the default in `@sentry/node`
and remove the `experimentalUseDiagnosticsChannelInjection()` opt-in.

`Sentry.init()` now installs the channel-injection module hooks unconditionally
when span recording is enabled, so the opt-in function, its loader indirection,
and the name-based OTel->channel integration swap are gone. The self-selecting
`dataloader` and `knex` integrations pick the channel path automatically now
that `isOrchestrionInjected()` is true by default.

Redis stays a composite integration: the native diagnostics-channel subscribers
(node-redis >=5.12, ioredis >=5.11, batches) plus the orchestrion subscribers
for the older ranges, all sharing the node cache `responseHook`. The vendored
OTel patchers only run on runtimes without `tracingChannel` (Node <18.19).

BREAKING CHANGE: `experimentalUseDiagnosticsChannelInjection()`,
`diagnosticsChannelInjectionIntegrations()`, `isDiagnosticsChannelInjectionEnabled()`
and `applyDiagnosticsChannelInjectionIntegrations()` are removed from
`@sentry/node`. Channel-based instrumentation is now always on; no opt-in call
is needed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Forward build-resolved tracingHooksDir in @sentry/nextjs server init so bundled
pnpm apps load the channel-injection hook.
Update span origins to orchestrion values (koa, hapi, nestjs, firebase functions)
and add error.type to errored express request_handler spans.
Skip preload and bring-your-own-OTel apps (node-express-cjs/esm-preload,
node-otel-sdk-node, node-otel-custom-sampler); fixme AI (ai@v3), trpc, and
firebase functions tests pending follow-ups.
node-koa: anonymous router middleware now resolves as 'middleware' via
code.function.name under the channel path.
Fixme trpc tests in tsx-express and node-express-v5 (same channel Express
mount-path naming gap as node-express).
Same channel Vercel AI v3-unsupported gap as nextjs-16; the turbo/latest
variants share this app dir so they're covered too.
…ress

The channel-based Express integration only resolved the route for
request_handler layers, so routes served through mounted middleware
(app.use('/trpc', handler)) never set http.route on the root span and their
transactions kept the raw URL name. Compute the matched route for every layer
type, mirroring the OTel Express integration's per-layer route resolution.

Re-enables the previously fixme'd trpc tests in node-express, tsx-express and
node-express-v5.
The aws-serverless `awsIntegration` still registered the vendored OTel
`AwsInstrumentation`, emitting `auto.otel.aws` spans, while channel-based
instrumentation is now the default everywhere else. Delegate to the channel
`awsChannelIntegration` from @sentry/server-utils so aws-sdk spans carry the
orchestrion origin, matching @sentry/node.
@andreiborza
andreiborza force-pushed the ab/channel-based-default branch from 921217b to e9cde04 Compare July 23, 2026 11:56
Channel-based instrumentation is bundled unconditionally now, growing the
@sentry/node bundle. Bump the limits to match (131->141 KB, without-tracing
80->81 KB) and drop the stale `experimentalUseDiagnosticsChannelInjection`
entry, whose export was removed.
type ExpressHandlerOptions,
} from '@sentry/core';
export { expressErrorHandler } from '@sentry/core';
import { expressChannelIntegration } from '@sentry/server-utils/orchestrion';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False missing instrumentation warnings

Low Severity

Default Express, Koa, and Hapi integrations now use orchestrion diagnostics-channel subscribers instead of OpenTelemetry monkey-patches, but setupExpressErrorHandler, setupKoaErrorHandler, and setupHapiErrorHandler still call ensureIsWrapped, which only detects OTel wrapping. Users with working channel instrumentation can get incorrect “not instrumented” warnings and missing_instrumentation context.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5713007. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Known gap: ensureIsWrapped only detects OTel monkey-patching, so channel-instrumented Express/Koa/Hapi can log false 'not instrumented' warnings. Tracked in JS-3128; disableInstrumentationWarnings silences it meanwhile. Not blocking (spans record correctly).

Update hardcoded OpenTelemetry origins to the channel values now that
channel-based instrumentation is the default (anthropic, apollo-graphql,
aws-serverless graphql, postgres-streamed). Rename graphql.source to
graphql.document to match the channel path, and guard the anthropic custom
options error-event expectation behind isOrchestrionEnabled() like its sibling
tests (the channel path marks the span errored but does not capture the handled
rejection as an event).
…tion in nextjs

hasSpansEnabled was called with unresolved options, so an app enabling tracing
only via SENTRY_TRACES_SAMPLE_RATE skipped registering the build-resolved
tracingHooksDir, while nodeInit still enabled channel injection with the bare
specifier (which fails in bundled Next server builds). Resolve the env var
first, matching @sentry/node's init.
Comment thread packages/nextjs/src/server/index.ts
…hooks

parseFloat of an invalid env value yields NaN, which is not nullish, so
hasSpansEnabled would treat tracing as enabled and disagree with @sentry/node.
Mirror node's getTracesSampleRate and drop non-finite env values.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 404fb86. Configure here.

mysqlIntegration(),
mysql2Integration(),
redisIntegration(),
...redisChannelIntegrations(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redis disable filter leaves channel integrations

Medium Severity

Spreading redisChannelIntegrations() into the default performance set registers three integrations (Redis, IORedis, RedisChannel) instead of one. Customizing defaults by removing only the Redis integration no longer turns off Redis tracing; the IORedis and RedisChannel subscribers still run and can emit spans.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 404fb86. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make channel-based instrumentations the default in v11

1 participant